import request from '@/utils/request'
import type { IResponseBody } from './userApi'

export interface IClass {
  id: number
  nickname: string
}

export interface IHW {
  id: number
  classId: number
  dirname: string
  startTime: string
  endTime: string
}

// 查找班级作业
export function getHWClassAll(id: number): Promise<IResponseBody<IClass[]>> {
  return request.get(`/hw/class?classId=${id}`)
}

export function addHW(data): Promise<IResponseBody<IHW>> {
  return request.post('/hw', data)
}

export function getHWStudentAll(classId: string, homeWorkId: string): Promise<IResponseBody<[]>> {
  return request.get(`/hw/all`, {
    params: {
      classId: classId,
      homeWorkId: homeWorkId
    }
  })
}

export interface IHWScore {
  classId: string | number
  stuId: string | number
  id: string | number
  homeWorkId: string | number
  score: string | number
}

/**
 * 评分
 * @param data
 * @returns
 */
export function hwScore(data: IHWScore): Promise<IResponseBody<[]>> {
  return request.post(`/hw/score`, data)
}
